using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GUIPanelWithButtons : GUIPanel {
	
	public List<GUIButton> buttons;
	
	public override void SendClic (Vector3 position)
	{
		base.SendClic (position);
		GetButtonByClicPosition(position);
	}
	
	GUIButton GetButtonByClicPosition(Vector3 clicPosition){
		foreach (GUIButton button in buttons){
			//Debug.Log("clic Position " + clicPosition);
			if (button.isPositionInsideButton(clicPosition) ){
				Debug.Log("Click sobre un boton");
				if (button.enabled)
					button.OnClickEvent(clicPosition);
				return button;
			}
		}
		return null;
	}
	
	public void EnableEditMode(bool active){
		foreach (GUIButton button in buttons){
            if (active && button.GetComponent<EventAttributeChange>() != null)
            {
                button.GetComponent<EventAttributeChange>().CheckActivation();
            }
            else if (button.GetComponent<EventAttributeChange>() != null)
            {
                button.gameObject.SetActive(false);
            }
		}
		this.transform.FindChild("CharacterIndex").gameObject.SetActive(active);	
	}
}